app.controller("specController",function ($scope,$controller,specService) {

    $controller("baseController",{$scope:$scope});

    $scope.spec={};
    $scope.list=[];
    $scope.entity={specEntity:{},specOption:[]};

    $scope.search=function (page,rows) {

        specService.findPageService(page,rows,$scope.spec).success(

            function (data) {
                $scope.list=data.rows;
                $scope.paginationConf.totalItems=data.total;

            }
        )
    }

    //新增
    $scope.addTableRow=function () {

        $scope.entity.specOption.push({});
    }
    //删除
    $scope.deleTableRow=function(index){

        $scope.entity.specOption.splice(index,1);
    }
  //添加
    $scope.save=function () {
        specService.saveService($scope.entity).success(
            function (data) {
                if(data.success){
                 $scope.reloadList();
                }else{
                    alert(data.message);
                }
            }
        )
    }
  //删除
    $scope.del=function () {
       specService.delService($scope.ids).success(function (data) {

           if(data.success){
               $scope.reloadList();
           }else{
               alert(data.message);
           }
       })
    }
    //回显
    $scope.finOne=function (id) {

        specService.findOneService(id).success(function (data) {

            $scope.entity=data;
        })
    }
})